package util;

import com.obs.services.ObsClient;

import java.io.File;

/**
 * @program: sijiacheng-obs-use
 * @create: 2023-06-29
 * 上传对象
 **/
public class OBSUploadFile {
    public static void main(String[] args) {
        // Endpoint请按实际情况填写。
        String endPoint = "https://obs.cn-south-1.myhuaweicloud.com";
        String ak = "RKN67AS*****LX55K";
        String sk = "ycddw9tac*****nC8cVLP2aANLmtQermn";
        // 创建ObsClient实例
        ObsClient obsClient = new ObsClient(ak, sk, endPoint);

        // localfile为待上传的本地文件路径，需要指定到具体的文件名
        obsClient.putObject("obs-ggj", "mytest1", new File("D:\\test\\obs\\aaa.txt"));

        // localfile2 为待上传的本地文件路径，需要指定到具体的文件名
//        PutObjectRequest request = new PutObjectRequest();
//        request.setBucketName("bucketname");
//        request.setObjectKey("objectkey2");
//        request.setFile(new File("localfile2"));
//        obsClient.putObject(request);

    }
}